package com.tiancheng.trade.settlement.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 交易类型
 */
@Getter
@AllArgsConstructor
public enum TransactionTypeEnum implements BaseEnum<String> {

    PAY("pay", "消费"),
    REFUND("refund", "退款"),
    ;

    private String code;
    private String desc;

    public static String getDesc(String code) {
        Optional<TransactionTypeEnum> found = Arrays.stream(TransactionTypeEnum.values()).filter(c -> c.code.equals(code)).findFirst();
        if (found.isPresent()) {
            return found.get().getDesc();
        }
        return "";
    }
}
